This is directed to an algorithm for detecting and processing button press events of an electronic device input mechanism.
Users can interact with electronic devices using different interfaces. In some embodiments, a user can interact with a device using a series of buttons, for example embedded within the electronic device, or coupled to the device using an accessory (e.g., buttons connected to a wired headset coupled to an audio jack of the electronic device). In some cases, the number of buttons provided can exceed the number of electric paths connected to an electronic device interface. For example, an electronic device can be coupled to a multi-button accessory that provides signals to the device using an audio jack. Because the audio jack can have two audio channels, a ground channel, and a microphone channel, and the audio channels typically cannot be interfered with (e.g., shorted to provide an instruction) without adversely affecting the quality of audio detected, the accessory and electronic device can require specialized circuitry for providing different signals using a single channel. One approach can include, for example, using a resistor network of varying resistance, or a component for outputting different audio tones based on a detected input (e.g., which of several buttons were pressed). Instead or in addition, the accessory can include a button that provides inputs to the device by shorting one of the audio jack channels (e.g., the microphone channel).
To determine which electronic device operation to perform in response to detecting an input, the electronic device can process inputs received from the multi-button accessory device to prioritize different detected inputs and ensure that all of the requested device operations are performed.